package com.hbnu.service.impl;

import com.hbnu.util.EmailUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;

@Service
@Slf4j
public class AsyncEmailService {
    // 邮箱发送工具
    @Autowired
    private EmailUtil emailUtil;
    @Async
    public void sendCodeAsync(String email, String text, String code) {
        try {
            emailUtil.sendCode(email, text, code);
            log.info("邮件发送成功：{}", email);
        } catch (Exception e) {
            log.error("邮件发送失败：{}，错误：{}", email, e.getMessage());
        }
    }
}